package com.laolang.shop.common.data.mvc.config;

import com.laolang.shop.common.data.mvc.interceptor.TraceInterceptor;
import com.laolang.shop.modules.auth.interceptor.AuthInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author khlbat
 * @version 1.0
 * @date 2020/11/1 20:46
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Autowired
    private TraceInterceptor traceInterceptor;

    @Autowired
    private AuthInterceptor authInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(traceInterceptor).addPathPatterns("/**");
        registry.addInterceptor(authInterceptor).addPathPatterns("/api/**", "/auth/**");
    }
}
